<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".detail").colorbox({width:"70%", height:"60%", iframe:true});
	$(".audit").click(function(){
		if ( ! confirm("确定审核其他入库单？"))
		{
			return false;
		}
	});
	$("#dialog_discount").dialog({autoOpen:false,modal:true})
	$(".discount").click(function(){
		$("#other_oi_id").val($(this).next().val());
		$("#dialog_discount").dialog("open");
	});
	$("#form_discount").submit(function(){
		if ($("#discount_value").val() == "")
		{
			return false;
		}
	});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>日期</th>
	<td>
		<input type="text" class="datepicker" name="begin_create_time" value="<?=isset($_GET['begin_create_time'])?$_GET['begin_create_time']:''?>" /> to 
		<input type="text" class="datepicker" name="end_create_time" value="<?=isset($_GET['end_create_time'])?$_GET['end_create_time']:''?>" />
	</td>
</tr>
<tr>
	<th>产品信息</th>
	<td><input type="text" name="product" value="<?=isset($_GET['product'])?$_GET['product']:''?>" /></td>
</tr>
<tr>
	<th>出库单号</th>
	<td><input type="text" name="number" value="<?=isset($_GET['number'])?$_GET['number']:''?>" /></td>
</tr>
<tr>
	<th>仓库</th>
	<td>
		<select name="warehouse_id" id="warehouse">
			<option value="">请选择..</option>
			<?foreach ($warehouse as $w):?>
			<option value="<?=$w['id']?>" <?if(isset($_GET['warehouse_id']) && $_GET['warehouse_id'] == $w['id'])echo "selected='selected'"?>><?=$w['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>仓库审核</th>
	<td>
		<?foreach (Q::ini('custom_flag/other_io_storage_audit') as $sa):?>
		<label><input type="checkbox" name="storage_audit[<?=$sa['value']?>]" value="<?=$sa['value']?>" <?=isset($_GET['storage_audit']) && in_array($sa['value'], $_GET['storage_audit']) ? 'checked="checked"' : ''?>> <?=$sa['name']?></label>
		<?endforeach;?>
	</td>
</tr>
<tr>
	<td></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form></fieldset>

<table width="100%" class="list_table">
<tr>
	<th width="120">单号</th>
	<th width="150">日期</th>
	<th width="100">类别</th>
	<th width="100">经办人</th>
	<th width="60">仓库</th>
	<th>备注</th>
	<th width="120">状态</th>
	<th width="100">操作</th>
</tr>
<?foreach ($other_io as $i):?>
<tr>
	<td><a class="detail" href="<?=url('Storage::OtherIO/Detail', array('id' => $i['id']))?>"><?=$i['number']?></a></td>
	<td><?=$i['create_time']?></td>
	<td><?=Helper_BSS_Normal::getIniOne('other_io_type', 'value', $i['type'], 'name')?></td>
	<td><?=$i['user_name']?></td>
	<td><?=$i['warehouse_name']?></td>
	<td align="left"><?=$i['notes']?></td>
	<td>
		<?=Helper_BSS_Normal::getIniOne('other_io_finance_audit', 'value', $i['finance_audit'], 'name')?><br/>
		<?=Helper_BSS_Normal::getIniOne('other_io_storage_audit', 'value', $i['storage_audit'], 'name')?>
	</td>
	<td>
		<?if ($i['storage_audit'] == Q::ini('custom_flag/other_io_storage_audit/audited/value')):?>
		<font color="#aaaaaa">审核 编辑</font>
		<?else:?>
		<a class="audit" href="<?=url('Storage::OtherIO/OutStorageAudit',array('id'=>$i['id'], Q::ini('unique_token_name')=>Helper_BSS_Normal::genToken()))?>">审核</a>
		<?if ($i['finance_audit'] == Q::ini('custom_flag/other_io_finance_audit/unaudited/value') && $i['storage_audit'] == Q::ini('custom_flag/other_io_storage_audit/unaudited/value')):?>
		<a href="<?=url('Storage::OtherIO/OutEdit', array('id'=>$i['id']))?>">编辑</a>
		<?endif;?>
		<?endif;?>
		<?if ($i['storage_audit'] == Q::ini('custom_flag/other_io_storage_audit/audited/value')):?>
		<a class="discount" href="javascript:void(0)">打折</a>
		<input type="hidden" value="<?=$i['id']?>" />
		<?endif;?>		
	</td>
</tr>
<?endforeach;?>
</table>
<div id="dialog_discount" title="出库单产品打折">
<form id="form_discount" method="post" action="<?=url('Storage::OtherIO/InCreate')?>">
<table class="form_table">
<tr>
	<th>折扣</th>
	<td>
		<input type="hidden" name="id" id="other_oi_id" />
		<select name="discount" id="discount_value">
			<option value="">请选择</option>
			<?for ($i = 1;$i <= 9;$i++):?>
			<option value="<?=$i?>"><?=$i;?>折（=<?=($i / 10);?>）</option>
			<?endfor;?>
		</select>
	</td>
</tr>
<tr>
	<th></th>
	<td><input type="submit" value="确认" class="button" /></td>
</tr>
</table>
</form>
</div>
<?=$page?>
<?php $this->_endblock();?>